package com.xxx.service;

import com.xxx.pojo.Account;

import java.util.Scanner;

/**
 * @version v1.0
 * @Description:
 * @Author zhanzhongxin
 * @Date 2021/7/15 9:31
 * @Copyright 博为峰
 */
public class ATM {
    public Scanner scanner;
    public Bank bank;

    public ATM() {
        scanner = new Scanner(System.in);
        bank = new Bank();
    }

    public void service() {
        System.out.println("请输入卡号");
        String cardNo = scanner.nextLine();
        System.out.println("请输入密码");
        String password = scanner.nextLine();
        Account account = bank.verify(cardNo, password);
        if (account != null) {
            do {
                System.out.println("1.存钱");
                System.out.println("2.取钱");
                String s = scanner.nextLine();
                switch (s) {
                    case "1":
                        System.out.println("请输入存款金额");
                        int money = Integer.parseInt(scanner.nextLine());
                        bank.saveMoney(account, money);
                        break;
                    case "2":
                        System.out.println("请输入取款金额");
                        double money2 = Double.parseDouble(scanner.nextLine());
                        bank.depositMoney(account, money2);
                        break;
                }
            } while (true);
        }
    }
}
